<?php
//=======================================
//###################################
// Kayako Web Solutions
//
// Source Copyright 2001-2004 Kayako Infotech Ltd.
// Unauthorized reproduction is not allowed
// License Number: $%LICENSE%$
// $Author: vshoor $ ($Date: 2007/01/05 20:57:52 $)
// $RCSfile: mobile_sync.php,v $ : $Revision: 1.5 $ 
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//###################################
//=======================================

if (!defined("INSWIFT")) {
	trigger_error("Unable to process $PHP_SELF", E_USER_ERROR);
}

$template->loadLanguageSection("staff_tickets");
$template->loadLanguageSection("tickets_auditlogs");
require_once ("./modules/tickets/functions_ticketsui.php");
require_once ("./modules/tickets/functions_ticketmain.php");
require_once ("./modules/tickets/functions_search.php");
require_once ("./modules/tickets/functions_ticketcore.php");
require_once ("./modules/tickets/functions_mobile.php");
require_once ("./includes/functions_xml.php");

$xml = new XML;

/**
* ###############################################
* SYNCFETCH
* ###############################################
*/
if ($eventaction == "syncfetch")
{
	$_assigns = getAssignedDepartments(MODULE_TICKETS);

	$_ticketviewid = getDefaultTicketView($_SWIFT["staff"]["staffid"]);

	$_ticketstatusid = $_departmentid = array();

	if (!empty($_REQUEST["ticketstatusid"]))
	{
		$_ticketstatusid = array(intval($_REQUEST["ticketstatusid"]));
	} else {
		$_ticketstatusid = getDisplayTicketStatusList();
	}

	if (!empty($_REQUEST["departmentid"]))
	{
		$_departmentid = array(intval($_REQUEST["departmentid"]));
	} else {
		$_departmentid = $_assigns;
	}

	if ($_SWIFT["staff"]["tmanage"] == "0")
	{
		exit;
	}

	$_tree = $xml->xml2tree($_POST["xml"]);

	$xml->addParentTag("mobile");
		dispatchMobileXML($_ticketviewid, $_departmentid, $_ticketstatusid, $_tree, $xml);
	$xml->endTag("mobile");

	$xml->echoXMLUTFWinapp();



/**
* ###############################################
* MOBILE PUSH FOR SAVED DATA IN KM
* ###############################################
*/
} else if ($eventaction == "mobilepush") {
	require_once ("./modules/tickets/mobile_push.php");




/**
* ###############################################
* MOBILE NEW TICET
* ###############################################
*/
} else if ($eventaction == "mobilenewticket") {
	require_once ("./modules/tickets/mobile_newticket.php");
}


?>